﻿Partial Public Class SetManulTimeFrame
    Private m_timeFrame As TimeFrame

    Public Property TimeFrame() As TimeFrame
        Get
            Return m_timeFrame
        End Get
        Set (ByVal value As TimeFrame)
            m_timeFrame = value
        End Set
    End Property

    Private Sub okButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

        Dim l_milliSeconds As Integer = 0
        Dim l_Seconds As Integer = 0
        Dim l_minutes As Integer = 0
        Dim l_MilliSecondsEnd As Integer = 0
        Dim l_SecondsEnd As Integer = 0
        Dim l_MinutesEnd As Integer = 0

        If Not TextBoxMilliSeconds.Text = String.Empty Then
            l_milliSeconds = TextBoxMilliSeconds.Text
        End If

        If Not TextBoxSeconds.Text = String.Empty Then
            l_Seconds = TextBoxSeconds.Text
        End If

        If Not TextBoxMinutes.Text = String.Empty Then
            l_minutes = TextBoxMinutes.Text
        End If

        If Not TextBoxMilliSecondsEnd.Text = String.Empty Then
            l_MilliSecondsEnd = TextBoxMilliSecondsEnd.Text
        End If

        If Not TextBoxSecondsEnd.Text = String.Empty Then
            l_SecondsEnd = TextBoxSecondsEnd.Text
        End If

        If Not TextBoxMinutesEnd.Text = String.Empty Then
            l_MinutesEnd = TextBoxMinutesEnd.Text
        End If

        m_timeFrame.FromTime = New TimeSpan(0, 0, l_minutes, l_Seconds, l_milliSeconds)
        m_timeFrame.ToTime = New TimeSpan(0, 0, l_MinutesEnd, l_SecondsEnd, l_MilliSecondsEnd)

        DialogResult = True

        RaiseEvent OnOkButtonClick(m_timeFrame)
    End Sub

    Public Sub New(ByVal p_event As EventBase)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()


        m_timeFrame = p_event.TimeFrame
        TextBoxMilliSeconds.Text = m_timeFrame.FromTime.Milliseconds
        TextBoxSeconds.Text = m_timeFrame.FromTime.Seconds
        TextBoxMinutes.Text = m_timeFrame.FromTime.Minutes

        TextBoxMilliSecondsEnd.Text = m_timeFrame.ToTime.Milliseconds
        TextBoxSecondsEnd.Text = m_timeFrame.ToTime.Seconds
        TextBoxMinutesEnd.Text = m_timeFrame.ToTime.Minutes




    End Sub


  
    Public Delegate Sub OnOkButtonClickDel(ByVal p_TimeFrame As TimeFrame)
    Public Event OnOkButtonClick As OnOkButtonClickDel


End Class
